﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using MetaTracker.ViewModel;

namespace MetaTracker.View
{
    /// <summary>
    /// Interaction logic for UserSelectionView.xaml
    /// </summary>
    public partial class UserSelectionView : UserControl
    {
        public UserSelectionView()
        {
            InitializeComponent();
            
            if (DataContext == null || !(DataContext is UserSelectionTabViewModel))
            {
                DataContext = new UserSelectionTabViewModel();
                Console.WriteLine("set data context");
            }

            this.passwordBox.PasswordChanged += new RoutedEventHandler(passwordBox_PasswordChanged);


        }

        
        ~UserSelectionView()
        {
            Debug.WriteLine("User Selection Destructor called!");
        }

        #region EventHandeling


        private void passwordBox_PasswordChanged(object sender, RoutedEventArgs e)
        {
            (DataContext as UserSelectionTabViewModel).Password = this.passwordBox.SecurePassword;
        }
        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
            e.Handled = true;
        }
        #endregion //EventHandeling
    }
}
